package com.itgungnir.diyshuo.fragment.danpin_fragment;

import android.util.Log;

import com.itgungnir.diyshuo.bean.DiyBean;
import com.itgungnir.diyshuo.bean.GoodsBean;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 单品页面的Presenter类
 */
public class DanPinPresenter implements DanPinContract.Presenter {
    private DanPinModel model;
    private DanPinContract.View view;

    public DanPinPresenter(DanPinContract.View view) {
        this.view = view;
        this.model = new DanPinModel();
    }

    @Override
    public void getDanPinFromNet(Map<String, String> params) {
        //mobile=no&version=4&module=forumdisplay&fid=36&page=1
        Map<String,String> map=new HashMap<>();
        map.put("mobile","no");
        map.put("version","4");
        map.put("module","forumdisplay");
        map.put("fid","36");
        map.put("page","1");
        model.getDanPinData(map, new DanPinContract.OnLoadDanPinListener() {
            @Override
            public void onSuccess(DiyBean diyBean) {
                List<GoodsBean> goodsBeanList=diyBean.getVariables().getForumThreadlist();
                view.onDanPinSuccess(goodsBeanList);
                Log.i("tag","---"+goodsBeanList);
            }

            @Override
            public void onFail(Exception e) {

            }
        });
    }
}
